package com.snow.conditions;

import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
 * TODO
 *
 * @author by 13119
 */
@Getter
@Setter
public class QueryCondition {

    /**
     * 列
     */
    String column;
    /**
     * 值
     */
    Object value;
    /**
     * 类型
     */
    ConditionType type = null;
    /**
     * 是否是查询组
     */
    Boolean groupCondition = false;

    Boolean subQuery = false;
    Class<?> subFrom = null;
    Class<?> subFieldType = null;
    String subField = "";
    ConditionType subQueryType = null;
    /**
     * 链接诶性
     */
    LinkType linkType = LinkType.AND;
    /**
     * 时间日期偏移
     */
    DayTimeOffset dayTimeOffset = DayTimeOffset.NONE;

    public QueryCondition(String column, Object value, ConditionType type) {
        this.column = column;
        this.value = value;
        this.type = type;
    }

    public QueryCondition(String column, Object value, QueryConditionField field) {
        this.column = column;
        this.value = value;
        this.type = field.type();
        this.groupCondition = field.groupCondition();
        this.subQuery = field.subQuery();
        this.subFrom = field.subFrom();
        this.subFieldType = field.subFieldType();
        this.subField = field.subField();
        this.subQueryType = field.subQueryType();
        this.dayTimeOffset = field.dateOffset();
    }



    public QueryCondition(LinkType linkType, List<QueryCondition> value) {
        this.value = value;
        this.groupCondition = true;
        this.linkType = linkType;
    }


}
